package com.cenntro.common.model.vo;

import com.cenntro.common.util.NumUtil;

import io.swagger.annotations.ApiModelProperty;

/**
 * 分页信息
 * @author Administrator
 *
 */
public class PageVO extends BaseVO {

    /**
     * 
     */
    private static final long serialVersionUId = -2296986889803890131L;

    @ApiModelProperty(value = "每页个数")
    private Integer limit = 10;

    @ApiModelProperty(value = "（page -1）*page 可以不填", hidden = true)
    private Integer offset = 0;

    @ApiModelProperty(value = "当前分页")
    private Integer page = 1;

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit == null ? 10 : limit;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = NumUtil.toInt(offset, 0);
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = NumUtil.toInt(page, 1);
        this.page = this.page < 1 ? 1 : this.page;
        this.offset = (this.page - 1) * NumUtil.toInt(limit, 10);
    }
}
